import java.util.Arrays;

public class Test {

        public static int removeElement(int[] nums, int val) {
            int count = 0;
            int[] temp = new int[nums.length];

            for(int i = 0;i <nums.length;i++){
                if(nums[i] == val){
                    nums[i] = 0;
                    count++;
                }
            }
            int c = 0;

            for(int j = 0 ; j < nums.length;j++){

                if(nums[j] != 0){
                    temp[c] = nums[j];
                    c++;
                }

            }
            for(int i = 0;i< temp.length;i++){
                nums[i] = temp[i];
            }
            return nums.length - count;
        }
        public static int[] fun(int[] nums1, int m, int[] nums2, int n){
            int[] nums = new int[m+n];
            for (int i = 0; i < nums1.length; i++) {
                nums[i] = nums1[i];
            }
            for (int j = 0; j < nums2.length; j++) {
                nums[m + j] = nums2[j];
            }
             nums1 = Arrays.copyOf(nums1,nums1.length + n);
            for (int i = 0; i < nums1.length; i++) {
                nums1[i] = nums[i];
            }
            Arrays.sort(nums1);
            return nums1;

        }

    public static void main(String[] args) {
            int [] nums1 = {1,2,4,5,5};
            int [] nums2 = {1,2,3,4,5};
             int[] array = fun(nums1,5,nums2,5);
        System.out.println(Arrays.toString(array));

    }
    public static void main1(String[] args) {
        int [] nums = {1,0,3,0,4,0,5,0,3,3,3,3};
        int k = 3;
        int c = removeElement( nums, k);
        System.out.println(Arrays.toString(nums));
        System.out.println(c);

    }
}
